package com.express.util;

import com.express.bean.User;
import com.express.bean.UserType;
import com.express.dao.impl.AdminDaoMysql;

import javax.servlet.http.HttpSession;

/**
 * @Author: laixiangdong
 * @Date 2020/12/06
 */
public class UserUtil {
    public static String getUserName(HttpSession httpSession) {
        String userName = (String) httpSession.getAttribute("userName");
        return userName;
    }

    public static String getUserPhone(HttpSession httpSession) {
        String userName = (String) httpSession.getAttribute("userName");
        AdminDaoMysql dao = new AdminDaoMysql();
        return dao.findSysPhone(userName);
    }

    public static String getWechatUserLoginCode(HttpSession httpSession, String userPhone) {
        String userWechatLoginCode = (String) httpSession.getAttribute(userPhone);
        return userWechatLoginCode;
    }

    public static void setWechatUserLoginCode(HttpSession httpSession, String userPhone, String code) {
        httpSession.setAttribute(userPhone, code);
    }

    public static void setWechatUserCode(HttpSession httpSession, String code) {
        httpSession.setAttribute("userCode", code);
    }

    public static String getWechatUserCode(HttpSession httpSession) {
        String userWechatCode = (String) httpSession.getAttribute("userCode");
        return userWechatCode;
    }

    public static void setWechatUserPhone(HttpSession httpSession, String userphone) {
        httpSession.setAttribute("wechatUserPhone", userphone);
    }

    public static String getWechatUserPhone(HttpSession httpSession) {
        return (String) httpSession.getAttribute("wechatUserPhone");
    }

    public static UserType getWechatUserType(HttpSession httpSession) {
        return (UserType) httpSession.getAttribute("wechatUserType");
    }

    public static void setWechatUserType(HttpSession httpSession, UserType type) {
        httpSession.setAttribute("wechatUserType",type);
    }

}
